import Cookies from 'js-cookie'
import request from "@/utils/request";

const AccessTokenKey = 'access-token'
const RefreshTokenKey = 'refresh-token'

export function getAccessToken() {
  return Cookies.get(AccessTokenKey)
}

export function getRefreshToken() {
  return Cookies.get(RefreshTokenKey)
}

export function setAccessToken(token) {
  return Cookies.set(AccessTokenKey, token)
}

export function setRefreshToken(refresh) {
  return Cookies.set(RefreshTokenKey, refresh)
}

export function removeAccessToken() {
  return Cookies.remove(AccessTokenKey)
}

export function removeRefreshToken() {
  return Cookies.remove(RefreshTokenKey)
}

// 刷新refresh
export function refreshToken(data) {
  return request({
    url: '/oauth/refresh/',
    method: 'post',
    data
  })
}
